package com.sike.netty.im.common.enums;


import com.sike.netty.im.common.command.*;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 指令类型枚举
 *
 * @author chenssy
 * @date 2023/09/14
 */
@Getter
@AllArgsConstructor
public enum CommandTypeEnum {
    LOGIN_REQUEST_COMMAND(1,"登录请求指令", LoginRequestCommand.class),
    LOGIN_RESPONSE_COMMAND(2,"登录响应指令", LoginResponseCommand.class),

    ONE_CHAT_REQUEST_COMMAND(3,"单聊请求指令", OneChatRequestCommand.class),
    ONE_CHAT_RESPONSE_COMMAND(4,"单聊响应指令", OneChatResponseCommand.class),

    CREATE_GROUP_REQUEST_COMMAND(5,"创建群聊请求指令", CreateGroupRequestCommand.class),
    CREATE_GROUP_RESPONSE_COMMAND(6,"创建群聊响应指令", CreateGroupResponseCommand.class),

    JOIN_GROUP_REQUEST_COMMAND(7,"加入群聊请求指令", JoinGroupRequestCommand.class),
    JOIN_GROUP_RESPONSE_COMMAND(8,"加入群聊响应指令", JoinGroupResponseCommand.class),

    LIST_GROUP_MEMBERS_REQUEST_COMMAND(9,"获取群聊成员请求指令", ListGroupMembersRequestCommand.class),
    LIST_GROUP_MEMBERS_RESPONSE_COMMAND(10,"获取群聊成员响应指令", ListGroupMembersResponseCommand.class),

    EXIT_GROUP_REQUEST_COMMAND(11,"退出群聊请求指令", ExitGroupRequestCommand.class),
    EXIT_GROUP_RESPONSE_COMMAND(12,"退出群聊响应指令", ExitGroupResponseCommand.class),

    GROUP_CHAT_REQUEST_COMMAND(13,"群聊请求指令", GroupChatRequestCommand.class),
    GROUP_CHAT_RESPONSE_COMMAND(14,"群聊响应指令", GroupChatResponseCommand.class),

    HEAR_BEAT_REQUEST_COMMAND(15,"心跳数据-请求", HearBeatRequestCommand.class),
    HEAR_BEAT_RESPONSE_COMMAND(16,"心跳数据-响应", HearBeatResponseCommand.class),
    ;

    /**
     * 指令类型
     */
    private Integer commandType;

    /**
     * 指令名称
     */
    private String commandName;

    /**
     * 指令请求 Class
     */
    private Class commandTypeClass;

    /**
     * 获取指令
     * @param commandType
     * @return
     */
    public static CommandTypeEnum getCommandType(Integer commandType) {
        for (CommandTypeEnum typeEnum : values()) {
            if (commandType.equals(typeEnum.getCommandType())) {
                return typeEnum;
            }
        }
        return null;
    }
}
